<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">知识词表管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>知识词表管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">词表分类</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">
		<div class="row mbl" >
			<div class="col-lg-6">
				<div class="input-group input-group-sm mbs">
					<span class="input-group-btn">
						<select id="queryParams" data-toggle="dropdown" class="btn btn-danger dropdown-toggle" style="width :100px;">
		                    <option value="-1">筛选项&nbsp;<span class="caret"></span></option>
		                    <option value="name_zh" selected="selected">中文名称</option>
		                    <option value="name_en">英文名称</option>
		                    <option value="description">描述</option>
                    	</select>
                   </span> 
                    	<input id="text" type="text" placeholder="请输入关键词..." class="form-control" /><span
						class="input-group-btn"><button type="button"
							data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="get()">搜索</button>
					</span>
				</div>
			</div>
			<div class="col-lg-6">
				<div class="tb-group-actions pull-right">
					<button class="btn btn-sm btn-primary" onclick="addUpdateUser('0')">新增
					</button>
				</div>
			</div>
		</div>
		<div class="row">
			<div id="tab-general" class="tab-general  col-lg-12">
				<div id="sum_box" class="sum_box row mbl " style=" height:640px;overflow-y :auto">
				</div>
				<!-- 其他区域展示如下 -->
			</div>
		</div>
		
		<div id="dataNull" class="panel-body" style="height: 90px; line-height: 50px;display:none;" align="center" >
			<span class='subtitle' style='font-size: 15px;'>数据为空!</span>
		</div>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var curr;
	var page;
	var id;
	$(function() {
		demo(1);
	});
	function getlay() {
		return id;
	}
	function getpage() {
		return page;
	}
	function addUpdateUser(lid) {
		id = lid;
		layer.open({
			type : 2,
			area : [ '420px', '400px' ],
		    scrollbar: false,
		    shadeClose: true,
			fix : false, //不固定
			title : '分类管理',
			//maxmin : true,  
			skin: 'layui-layer-rim', //加上边框
    	    		btn: ['保存 ', '关闭'],
			content : ["word-module-add-update.html",'no'],
			yes: function(index,layer){
	            var iframeWin = parent.window[layer.find('iframe')[0]['name']];
	            iframeWin.Page();
	         },
			cancel : function(index) {
			}
		});
	}
	function del(id,curr) {
		if (confirm("是否确认删除！！")) {
			$.ajax({
				type : "post",
				url : "deleteWordModule.do",
				data : {
					"id" : id
				},
				dataType : "json",
				success : function(data) {
					demo(curr);
					if(data[0].data == 'yes'){
						parent.layer.msg('删除成功！');
					}else{
						parent.layer.msg('删除失败！');
					}
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
	}
	function demo(curr) {
		$.getJSON("getModuleList.do",
			{
				page : curr || 1,
				queryParams:$("#queryParams").val(),
        		text:$("#text").val(),
			},
			function(res) {
				//此处仅仅是为了演示变化的内容
				var str = "";
				if(res[0].count == 0){
					document.getElementById('dataNull').style.display='block';
				}
				for ( var i = 0; i < res[0].list.length; i++) {
					var colour="";
     	    		if(res[0].list[i].count<10){
     	    			colour ="progress-bar-success";
     	    		}else if(res[0].list[i].count>=10 && res[0].list[i].count<20){
     	    			colour ="progress-bar-info";
     	    		}else if(res[0].list[i].count>=20 && res[0].list[i].count<30){
     	    			colour ="progress-bar-warning";
     	    		}else if(res[0].list[i].count>=30){
     	    			colour ="progress-bar-danger";
     	    		}
					 str+='<div class="col-sm-12 col-md-6">'
	                	+'<a href="word-thesaurus-list.html?id='+res[0].list[i].id+'">'
		                 +'<div class="panel yellow db mbm">'
		                   +'<div class="panel-body" style="min-height: 200px;">'  
		                       +'<p class="icon"><i class="icon fa iconfont icon-zhishiku"></i>'   
		                          +'</p>'
		                          +'<h4 class="value" style="line-height: 40px;"><span style="display: inline-block;min-width: 250px;">'+res[0].list[i].nameZh+'</span><a href="JavaScript:addUpdateUser('+res[0].list[i].id+');" style="font-size: 16px;color: #3a95f5;margin-left:25px;border: 1px solid #3a95f5;padding: 4px 11px;">编辑</a><a href="JavaScript:del('+res[0].list[i].id+')" style="font-size: 16px;color: #3a95f5;margin: 0px 25px;border: 1px solid #3a95f5;padding: 4px 11px;">删除</a></h4>'  
		                           +'<p class="description" style="margin-top: 15px;font-size: 20px;">'+res[0].list[i].count+'条</p>' 
		                             +'<div class="progress progress-sm mbn">'
		                               +'<div role="progressbar" aria-valuenow="'+res[0].list[i].count+'" aria-valuemin="0" aria-valuemax="100" style="width:'+res[0].list[i].count+'%;" class="progress-bar '+colour+'"><span class="sr-only">'+res[0].list[i].count+'% Complete (success)</span>'   
		                              +'</div>'
		                            +'</div>'
		                            +'<p style="text-indent: 20px;line-height: 25px;margin-top: 10px;margin-bottom: 0px;">'
		                              + res[0].list[i].description
		                            +'</p>' 
		                        +'</div>'
		                    +'</div>'
	                   +'</a>' 
	               +'</div>' ;
				
				
					/* str += "<tr><td>"
							+ (i + 1)
							+ "</td><td>"
							+ res[0].list[i].nameZh
							+ "</td><td>"
							+ res[0].list[i].nameEn
							+ "</td><td>"
							+ res[0].list[i].description
							+ "</td><td>"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"addUpdateUser('"
							+ res[0].list[i].id
							+ "')\">"
							+ "编辑"
							+ "</button>&nbsp;"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"del('"
							+ res[0].list[i].id
							+ "','"+ curr+ "')\">"
							+ "删除"
							+ "</button>" + "</td></tr>"; */
				}
				$("#sum_box").html(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res[0].page, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: res[0].page,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
			                 curr=obj.curr;
			                 page=obj.curr;
						}
					}
				});
			});
	};

	
</script>